package copyengine.ui.component.list.old.animation
{
	import com.greensock.TweenLite;
	
	import copyengine.ui.component.list.old.cellrender.ICEOldCellRender;
	
	import flash.display.DisplayObjectContainer;

	public class CEListCellRenderTweenAnimation implements ICEListCellRenderAnimation
	{
		/**
		 * define how long the tween is.
		 */
		private static const TWEEN_TIME:Number = 0.2;

		/**
		 * rolloverScal = normalScale * ROLL_OVER_SCAL_PERCENT;
		 * clickScal = normalScale * CLICK_SCAL_PERCENT;
		 */
		private static const ROLL_OVER_SCAL_PERCENT:Number = 1.08;
		private static const CLICK_SCAL_PERCENT:Number = 1;

		/**
		 * button skin maybe scaled  so need an value to remember the button initial value .
		 */
		private var normalScaleX:Number;
		private var normalScaleY:Number;


		private var cellRenderContainer:DisplayObjectContainer

		public function CEListCellRenderTweenAnimation()
		{
		}

		public function set target(_cellRenderContainer:DisplayObjectContainer):void
		{
			cellRenderContainer = _cellRenderContainer;
			normalScaleX = cellRenderContainer.scaleX;
			normalScaleY = cellRenderContainer.scaleY;
		}

		public function dispose() : void
		{
			TweenLite.killTweensOf(cellRenderContainer);
			cellRenderContainer = null;
		}

		public function onRollOver() : void
		{
			TweenLite.killTweensOf(cellRenderContainer,true);
			TweenLite.to(cellRenderContainer,TWEEN_TIME,{scaleX:normalScaleX*ROLL_OVER_SCAL_PERCENT  ,scaleY :normalScaleY*ROLL_OVER_SCAL_PERCENT });
		}

		public function onRollOut() : void
		{
			TweenLite.killTweensOf(cellRenderContainer,true);
			TweenLite.to(cellRenderContainer,TWEEN_TIME,{scaleX:normalScaleX * CLICK_SCAL_PERCENT ,scaleY :normalScaleY * CLICK_SCAL_PERCENT});
		}
		
		public function onSelect(_isSelected:Boolean):void
		{
		}
	}
}